<template>
	<view>
		<view class="u-form-item">
			<view class="name">姓名</view>
			<u--input placeholder="姓名" customStyle="background:#f4f9fb;" v-model="forms.name"></u--input>

			<view class="name">电话</view>
			<u--input placeholder="电话" customStyle="background:#f4f9fb;" v-model="forms.mobile"></u--input>

			<view class="name">份数</view>
			<u--input placeholder="份数" customStyle="background:#f4f9fb;" v-model="forms.num"></u--input>

			<view class="name">邮编</view>
			<u--input placeholder="邮编" customStyle="background:#f4f9fb;" v-model="forms.code"></u--input>

			<view class="name">地址</view>
			<u--input placeholder="地址" customStyle="background:#f4f9fb;" v-model="forms.address"></u--input>
			<view class="name">挂号</view>
			<u-switch v-model="forms.is_special" :activeValue="1" :inactiveValue="0"></u-switch>

			<u-button type="primary" text="确定添加" style="margin-top:40rpx;" @click="addAddress"></u-button>

		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import {
		getOrderList,
		addOrder
	} from 'config/api.js';
	export default {
		data() {
			return {
				forms: {
					id:0,
					name: '',
					mobile: '',
					num: '1',
					code: '',
					address: '',
					is_special: 0
				}
			}
		},
		onReachBottom() {

		},


		computed: {
			...mapState(['hasLogin', 'userInfo']),
		},
		onLoad() {

		},
		methods: {
			addAddress() {
				let address = uni.getStorageSync('address') || []
				address.push(this.forms)
				uni.setStorageSync('address', address)
				this.forms = {
					name: '',
					mobile: '',
					num: '1',
					code: '',
					address: '',
					is_special: 0
				}
				
				var pages = getCurrentPages();
				var prePage = pages[pages.length - 2] 
				 
				uni.navigateBack({
					delta:1,
					success() {
						prePage.$vm.address_load()
					}
				})
		
			}
		}
	}
</script>

<style>
	page {
		padding: 40rpx;
		/* background-color: #f5f5f5; */
	}

	.address {
		border: 1px solid #b3d2f1;
		border-radius: 10rpx;
		padding: 10rpx;
		margin: 30rpx 0;

		.name {
			padding: 10rpx 0;
			text-align: center;
			width: 100%;
			color: #3c9cff !important;
			margin: 0 !important;

			&:hover {
				background-color: #eee;
			}
		}
	}

	.select_input {
		background-color: #f4f9fb;
		padding: 12rpx 18rpx;
		width: 400rpx;
	}

	.u-form-item {
		.name {
			font-size: 32rpx;
			color: #000;
			margin: 30rpx 0 20rpx 0;
		}
	}
</style>